﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;
using System.ComponentModel.DataAnnotations;

namespace PromoCodes_Models.Entities
{
    public class Promotion
    {
        [HiddenInput]
        public int PromotionID { get; set; }

        [Required]
        [MaxLength(50)]
        public string PromotionCode { get; set; }

        [Required]
        public int discountTypeValue { get { return (int)DiscountType; } set { DiscountType = (DiscountType)value; } }
        [NotMapped]
        public DiscountType DiscountType { get; set;}

        [Required]
        [Range(1, 100)]
        public float DiscountPercentage { get; set; }

        [MaxLength(1000)]
        public string Notes { get; set; }

        [DataType(DataType.Date)]
        [DisplayFormat(DataFormatString = "{0:dd/MM/yyyy}", ApplyFormatInEditMode = true)]
        public DateTime Expiration { get; set; }

        public uint MaxUses { get; set; }

        [ForeignKey("Product")]
        public int? ProductID { get; set; }

        public Product Product { get; set; }

        public float MinimumTotalOrder { get; set; }
    }

    public enum DiscountType
    {
        PRODUCT,
        ORDER
    }
}